package util;

import java.util.Comparator;
import java.util.Map;

public class VolumeComparator implements Comparator<String> {

    Map<String, Triplet<Candle, Candle, Candle>> base; 
    
    public VolumeComparator(Map<String, Triplet<Candle, Candle, Candle>> base) { 
        this.base = base; 
    } 
 
	@Override
	public int compare(String s1, String s2) {
		Triplet<Candle, Candle, Candle> t1 = base.get(s1);
		Triplet<Candle, Candle, Candle> t2 = base.get(s2);
		
    	Candle c1 = (Candle) t1.getC();
    	Candle c2 = (Candle) t2.getC();
    	
    	Integer v1 = c1.getVolume();
    	Integer v2 = c2.getVolume();

    	int result = -v1.compareTo(v2);
    	//if (result == 0) result = 1;
        return result;
	}
}
